<?php

	class objRsrc extends rsrcHandle{
		
		protected $data;
		
		function __construct($rsrc, $mode='r', $skip=0){
			parent::__construct($rsrc, $mode, $skip);
			$this->data = new obj;
		}
		
		function __get($k){
			return $this->data->get($k);	
		}
		
		function __set($k, $v){
			$this->data->set($k, $v);	
		}
		
		function set($k, $v){
			$this->data->set($k, $v);
		}
		
		function obj(){
			return $this->data;	
		}
		
		function read(){
			if(!$this->handle){
				if(!$this->open('r')) return false;
			}elseif(!$this->is_readable()) return false;
			$d = '';
			while($ln = fread($this->handle, 1024)) $d .= $ln;
			if($u = @unserialize($d)) $this->data = new obj($u);
			else trigger_error(get_class($this)." unable to unserialize data in $this->rsrc", E_USER_NOTICE);
			return (bool)$u;	
		}
		
		function write(){
			if((!$this->handle)&&(!$this->open('w'))) return false;
			$n = fwrite($this->handle, serialize($this->data));
			$this->close();
			return is_integer($n);
		}
		
	}


